<!DOCTYPE html>
<html>
<head>
    <title>js面向对象--原型继承-1</title>
    <meta charset="utf-8"/>
    <script>
//        function Person() {
//            this.name = "Mike";
//            this.sayGoodbye = function () {
//                alert("GoodBye!");
//            };
//        }
//        Person.prototype.sayHello = function () {
//            alert("Hello!");
//        };
//
//        ////////////////////////////////////////////////////
//        function Student() {
//        }
//        Student.prototype = new Person();

        function Person(name){
            this.name = name;
        }

        Person.prototype.sayHello = function(){alert(this.name + " say Hello!");};

        function Student(name,id){
            Person.call(this,name);
            this.id = id;
        }

        Student.prototype = new Person();
        Student.prototype.show = function() {
            alert("Name is:" + this.name + " and Id is:" + this.id);
        };

        var stu = new Student("gaolei", 11);
        //stu.sayGoodbye();
        stu.sayHello();
        stu.show();

    </script>
</head>
<body>

</body>
</html>